package logx

import (
	"gitee.com/zhongguo168a/gocodes/myx/logx/iface"
	"sync"
)

var loggers = &sync.Map{}

// RegisterDefault 注册默认的日志处理器
func RegisterDefault(val iface.ILogger) {
	logger = val
}

// RegisterLogger 注册指定标签[key]的日志处理器
// 关联 logx.UseLogger
func RegisterLogger(key string, val iface.ILogger) {
	loggers.Store(key, val)
}

// UseLogger 获取指定的日志处理器
func UseLogger(key string) (val iface.ILogger) {
	ival, ok := loggers.Load(key)
	if ok == false {
		panic("logger not found: " + key)
	}
	val = ival.(iface.ILogger)
	return
}
